<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%bai_rong_validate_for_credit_order}}".
 *
 * @property int $id
 * @property int $credit_order_id
 * @property int $bai_rong_validate_log_id
 * @property int $created_at
 *
 * @property CreditOrder $creditOrder
 * @property BaiRongValidateLog $baiRongValidateLog
 */
class BaiRongValidateForCreditOrder extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%bai_rong_validate_for_credit_order}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['credit_order_id', 'bai_rong_validate_log_id', 'created_at'], 'required'],
            [['credit_order_id', 'bai_rong_validate_log_id', 'created_at'], 'integer'],
            [['credit_order_id', 'bai_rong_validate_log_id'], 'unique', 'targetAttribute' => ['credit_order_id', 'bai_rong_validate_log_id']],
            [['credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => CreditOrder::className(), 'targetAttribute' => ['credit_order_id' => 'id']],
            [['bai_rong_validate_log_id'], 'exist', 'skipOnError' => true, 'targetClass' => BaiRongValidateLog::className(), 'targetAttribute' => ['bai_rong_validate_log_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'credit_order_id' => Yii::t('app', 'Credit Order ID'),
            'bai_rong_validate_log_id' => Yii::t('app', 'Bai Rong Validate Log ID'),
            'created_at' => Yii::t('app', 'Created At'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreditOrder()
    {
        return $this->hasOne(CreditOrder::className(), ['id' => 'credit_order_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getBaiRongValidateLog()
    {
        return $this->hasOne(BaiRongValidateLog::className(), ['id' => 'bai_rong_validate_log_id']);
    }
}
